package n18_犹豫模式_在n17基础上优化;

/**
 * @author fu
 * @date 2022-01-16 21:02
 * 概要：
 * -------------------------------------------------------------
 * |                                                           |
 * |      Balking 犹豫模式 ：还未用来 实现线程安全的 单例           |
 * |                                                           |
 * |============================================================
 */
public class T2_Singleton {

    private T2_Singleton() {
    }
    private static T2_Singleton INSTANCE = null;
    // 懒惰初始化 饿汉式单例 ； 不为空 才创建
    public static synchronized T2_Singleton getInstance() {
        if (INSTANCE != null) {
            return INSTANCE;
        }

        INSTANCE = new T2_Singleton();
        return INSTANCE;
    }

}
